import { WebView } from "@tarojs/components";
import Taro from "@tarojs/taro";
import { useRouter } from "@tarojs/taro";
import { useUserInfo } from "@/store/userDataContext";

function WebViewContainer() {
  const { userInfoState } = useUserInfo();
  const { liveLink } = userInfoState;
  let { params } = useRouter();
  console.log('params: ', params);
  const mode = params.mode && params.mode;
  const link = params.link && params.link;
  const name = params.name && params.name;

  Taro.setNavigationBarTitle({
    title: name || "",
  });

  const src =
    mode === "live" ? (liveLink && liveLink) || "" : (link && link) || "";


  return <WebView src={src} />;
}

export default WebViewContainer;
